package com.einmeer.hfbank.controller;

import com.einmeer.hfbank.service.DepositService;
import com.einmeer.hfbank.vo.ResultVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author 芊嵛
 * @date 2024/1/13
 */
@RestController
@RequestMapping("/deposit")
public class DepositController {
    @Resource
    private DepositService depositService;

    /**
     * 根据卡号和类型查询存款
     * @param cardNumber
     * @param depositType
     * @return
     */
    @GetMapping("/queryAllByCardNumber/{cardNumber}/{depositType}")
    @CrossOrigin
    public ResultVo queryAllByCardNumber(@PathVariable("cardNumber") Long cardNumber, @PathVariable("depositType") Integer depositType){
        return depositService.queryAllByCardNumber(cardNumber, depositType);
    }

    /**
     * 活期转定期
     * @param depositAmount
     * @param depositType
     * @param cardNumber
     * @return
     */
    @PostMapping("/transformPeriodical/{depositAmount}/{depositType}/{cardNumber}")
    @CrossOrigin
    public ResultVo transformPeriodical(@PathVariable("depositAmount") String depositAmount, @PathVariable("depositType") Integer depositType, @PathVariable("cardNumber") Long cardNumber){
        return depositService.transformPeriodical(depositAmount, depositType, cardNumber);
    }

    /**
     * 查询所有定期存款
     * @param cardNumber
     * @return
     */
    @GetMapping("/queryAllFroPeriodical/{cardNumber}")
    @CrossOrigin
    public ResultVo queryAllFroPeriodical(@PathVariable("cardNumber") Long cardNumber){
        return depositService.queryAllFroPeriodical(cardNumber);
    }

    /**
     * 定期转活期
     * @param depositId
     * @return
     */
    @PutMapping("/transformCurrent/{depositId}")
    @CrossOrigin
    public ResultVo transformCurrent(@PathVariable("depositId") Long depositId){
        return depositService.transformCurrent(depositId);
    }
}
